package io.gitee.sfch.chunmi.controller.system;


import io.gitee.sfch.chunmi.common.tree.BaseTreeNode;
import io.gitee.sfch.chunmi.entity.Response;
import io.gitee.sfch.chunmi.dao.system.entity.SystemMenu;
import io.gitee.sfch.chunmi.service.system.SystemMenuService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 系统菜单
 */
@RestController
@RequestMapping("/system/menu")
public class SystemMenuController {

    @Resource
    private SystemMenuService systemMenuService;

    /**
     * 获取某个产品下的菜单树形
     *
     * @param productId 产品ID
     */
    @GetMapping("/findTree")
    public Response<List<BaseTreeNode<SystemMenu>>> findMenuTree(@RequestParam("productId") Long productId) {
        List<BaseTreeNode<SystemMenu>> menuList = systemMenuService.findMenu(productId);
        return Response.success(menuList);
    }
}
